package client

import (
	"github.com/micro/go-micro/v2"
	"github.com/micro/go-micro/v2/registry"
	"github.com/micro/go-plugins/registry/consul/v2"
	"micro/proto/rand"
)

var (
	randClient rand.RandService
)

func GetRandClient() rand.RandService {
	if randClient == nil {
		consulReg := consul.NewRegistry(registry.Addrs("127.0.0.1:8500"))
		service := micro.NewService(micro.Registry(consulReg))

		randClient = rand.NewRandService("go.micro.test.rand", service.Client())
	}
	return randClient
}
